package com.cseg674.dataentry.javaparser;
import java.util.LinkedList;
 
/**
    * RdfClass provides the attributes and methods that define a Class in the RDF output. 
    */

public class RdfClass extends RdfTreeNode{
    
    private LinkedList<RdfMethod> methods;
    private LinkedList<RdfField> fields;
    private LinkedList<RdfConstructor> contructors;
    private RdfClass superclass;
    private LinkedList <RdfInterface> superInterfaces;
    private LinkedList <String> imports;
    private RdfMethod currentMethod = null;
    
    private boolean hasSuperClass = false;
    
    /** Creates a new instance of RdfClass */
    public RdfClass() {
        this("default");
    }
    public RdfClass(String name){
        this("default", name, null);
    }
    public RdfClass(String name, String type){
        this("default", name, type);
    }
    public RdfClass(String perfix, String name, String type) {
        this(perfix, name, type, null);
    }
    public RdfClass(String perfix, String name, String type, RdfClass superclass) {
        super(perfix, name, type);
        methods = new LinkedList <RdfMethod>();
        fields = new LinkedList <RdfField>();
        contructors = new LinkedList <RdfConstructor>();
        superInterfaces = new LinkedList <RdfInterface>();
        imports = new LinkedList <String>();
        this.superclass = superclass;
    }
    
	/**
     * Returns the methods list
     * @param None
     * @return a linked list of methods
     */
    public LinkedList<RdfMethod> getMethods() {
        return methods;
    }
	
	/**
     * Returns the fields list
     * @param None
     * @return a linked list of fields
     */
    public LinkedList<RdfField> getFields() {
        return fields;
    }
	
	/**
     * Returns the constructors list
     * @param None
     * @return a linked list of constructors
     */
    public LinkedList<RdfConstructor> getContructors() {
        return contructors;
    }
	
	/**
     * Returns the superinterfaces list
     * @param None
     * @return a linked list of superinterfaces
     */
    public LinkedList <RdfInterface> getSuperInterfaces() {
        return superInterfaces;
    }
    /**
     * Returns the constructors list
     * @param The linked list index of the superinterface
     * @return The superinterface at index i
     */
	public RdfInterface getSuperInterface(int i) {
        return getSuperInterfaces().get(i);
    }
    
	/**
     * Returns the imports list
     * @param None
     * @return a linked list of imports
     */
	public LinkedList <String> getImports() {
        return imports;
    }
    
	/**
     * Make a class the super class
     * @param RdfClass
     * @return None
     */
	public void setSuperclass(RdfClass s) {
        superclass = s;
        hasSuperClass = true;
    }
    
	/**
     * Check whether a class has a superclass or not
     * @param None
     * @return boolean
     */
	public boolean hasSuperClass() {
    	return hasSuperClass;
    }
    
	/**
     * Get the superclass of a given class
     * @param None
     * @return RdfClass
     */
	public RdfClass getSuperclass() {
        return superclass;
    }
    
	/**
     * Add a superinterface to the superinterfaces linked list
     * @param RdfInterface
     * @return boolean
     */
	public boolean addSuperInterface(RdfInterface s) {
        return superInterfaces.add(s);
    }
    
	/**
     * Add an import to the imports linked list
     * @param String
     * @return boolean
     */
	public boolean addImport(String s) {
        return imports.add(s);
    }
    
	/**
     * Add a method to the methods linked list
     * @param RdfMethod
     * @return boolean
     */
	public boolean addMethod(RdfMethod a) {
        currentMethod = a;
        return methods.add(a);
    }
    
	/**
     * Add a field to the fields linked list
     * @param RdfField
     * @return boolean
     */
	public boolean addField(RdfField a) {
        return fields.add(a);
    }
    
	/**
     * Add a constructor to the constructors linked list
     * @param RdfConstructor
     * @return boolean
     */
	public boolean addContructor(RdfConstructor a) {
        return contructors.add(a);
    }
    
	/**
     * Add method a at index i of the linked list
     * @param int
	 * @param RdfMethod
     * @return None
     */
	public void addMethod(int i, RdfMethod a){
        currentMethod = a;
        methods.add(i, a);
    }
    
	/**
     * Add an rdf param to the current method
	 * @param RdfParam
     * @return None
     */
	public void addParam(RdfParam p){
        currentMethod.addParam(p);
    }
    
	/**
     * Add an Rdf method call to the current method
	 * @param RdfMethod
     * @return None
     */
	public void addCalls(RdfMethod m){
        currentMethod.addCalls(m);
    }
    
	/**
     * Add a "modifies" to the current method
	 * @param RdfField
     * @return None
     */
	public void addModifies(RdfField f){
        currentMethod.addModifies(f);
    }
	
    /**
     * Get the RdfMethod at index i
	 * @param int
     * @return RdfMethod
     */
	public RdfMethod getMethod(int i){
        return getMethods().get(i);
    }
    
	/**
     * Get the RdfField at index i
	 * @param int
     * @return RdfField
     */
	public RdfField getField(int i){
    	return getFields().get(i);
    }
    
	/**
     * Get the size of the methods linked list
	 * @param None
     * @return int
     */
	public int sizeOfMethods() {
        return getMethods().size();
    }
    
	/**
     * Get the size of the fields linked list
	 * @param None
     * @return int
     */
	public int sizeOfFields() {
        return getFields().size();
    }
    
	/**
     * Get the size of the superinterfaces linked list
	 * @param None
     * @return int
     */
	public int sizeOfInterfaces() {
        return getSuperInterfaces().size();
    }
}